﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using EZCRS.HCMS.Bll.baseinfo;
using EZCRS.HCMS.Entity;
using EZCRS.HCMS.Bll;
using OTA.Notification.BO.Dictionary;

namespace EZCRS.HCMS.Web.manage.setup
{
    public partial class partner_add : ManageBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            CheckModule(78);
            if (!Page.IsPostBack)
            {
                ddlPARTNER_TYPE.DataSource = new DictionaryBO().getAllDictionary("UIT", OTA.Notification.Common.DicType.Common, OTA.Notification.Common.LanguageType.English);
                ddlPARTNER_TYPE.DataTextField = "name";
                ddlPARTNER_TYPE.DataValueField = "value";
                ddlPARTNER_TYPE.DataBind();

                ddlCOMPANY_CODE.DataSource = new BllHCRS_COMPANY().getitem("");
                ddlCOMPANY_CODE.DataTextField = "SHORT_NAME";
                ddlCOMPANY_CODE.DataValueField = "COMPANY_CODE";
                ddlCOMPANY_CODE.DataBind();

                int id = CFun.RequestNumber("id");
                if (id > 0)
                {
                    HCRS_PARTNER partner = new BllHCRS_PARTNER().getitem(id);
                    if (partner != null)
                    {
                        CFun.bindpagedata<HCRS_PARTNER>(this, partner);


                    }
                }
            }
        }

        protected void BtnAdd_Click(object sender, EventArgs e)
        {
            HCRS_PARTNER partner = new HCRS_PARTNER();

            CFun.getpagedata<HCRS_PARTNER>(partner, this);

            partner.LAST_UPDATE_TIME = DateTime.Now.ToString();
            partner.LAST_USER_NAME = base.BasUserName;
            if (partner.id == 0)
            {
                partner.CREATE_TIME = DateTime.Now;
                partner.CREATE_USER_NAME = base.BasUserName;
            }

            if(new BllHCRS_PARTNER().insertorupdateitem(partner))
                Response.Write(CFun.AlertMeg(Resources.Site.LabAddressList + Resources.Site.SystemModifySuccess, "", "partner.aspx"));
            else
                Response.Write(CFun.AlertMeg(Resources.Site.SystemError, "back", ""));

        }
    }
}
